package com.tanhua.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.manage.domain.Log;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

public interface LogMapper extends BaseMapper<Log> {

    //查询登陆次数、注册人数
    @Select("SELECT COUNT(user_id) FROM tb_log WHERE TYPE=#{type} AND log_time=#{now}")
    Long queryNumsByType(@Param("now") String now,@Param("type") String type);

    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE  log_time=#{now}")
    Long queryNumsByDate(String now);

    @Select("SELECT COUNT(DISTINCT user_id) FROM tb_log WHERE log_time=#{now} AND user_id IN(\n" +
            "\n" +
            "SELECT user_id FROM tb_log WHERE TYPE='0102' AND  log_time=#{yesterday})")
    Long queryRetention1d(@Param("yesterday") String yesterday, @Param("now") String now);
}
